package com.graduation.apiservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.po.Law;
import com.graduation.pojo.query.LawQuery;
import com.graduation.pojo.vo.LawVO;
import com.graduation.service.LawService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/law")
@RequiredArgsConstructor
public class LawController {

    private final LawService lawService;

    /**
     * 分页查询法律条款（前台接口）
     * 通过documentId查询相关法律条款
     */
    @GetMapping("/page")
    public PageDTO<LawVO> pageLaws(LawQuery query) {
        return lawService.pageLaws(query);
    }

    /**
     * 查看法律条款详情
     */
    @GetMapping("/{id}")
    public Law getLawById(@PathVariable("id") Long id) {
        return lawService.getLawById(id);
    }

}
